from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render_to_response
from django.core import serializers
from pplsearch.logic import *
from pplsearch.models import *
import logging

def search_by_description(request):
    description = request.POST["description"]
    logging.debug('got desc: %s' % description)
    assert len(description)>0
    concepts = analyze_description(description)
    if len(concepts) == 0:
        result = "{}"
        logging.debug('returning result %s' % result)
        return HttpResponse(result)
    concept_ppl_relations = search_ppl_by_concepts(concepts)
    #concept_ppl_relations = mock_search_ppl_by_concepts(concepts)
    return render_to_response("graph.json", locals())


def view_person(request, nickname):
    entries = get_person_entries(nickname)
    #entries = mock_get_person_entries(nickname)
    return render_to_response("entries.json", locals())
